﻿using Abp.Web.Mvc.Authorization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WanFang.Test;
using WanFang.Web.Controllers;

namespace WanFang.Web.Controller
{
    [AbpMvcAuthorize]
    public class TestDrawController : WanFangControllerBase
    {
        private IHistoryDataService _service;
        public TestDrawController(IHistoryDataService service)
        {
            _service = service;
        }
        // GET: Test
        public ActionResult List()
        {
            var lst = _service.GetList();
            return View();
        }
        public ActionResult GetData()
        {
            Random ran = new Random();
            var m = new HistoryData();
            m.MachineCode = "1103-" + ran.Next(1, 19);
            m.Yw = Convert.ToDecimal(ran.NextDouble() * 4000);
            m.Kd = Convert.ToDecimal(ran.NextDouble() * 90);
            m.Wd = Convert.ToDecimal(ran.NextDouble() * 100);
            m.GnYl = Convert.ToDecimal(ran.NextDouble() * 0.3);
            m.JtYl = Convert.ToDecimal(ran.NextDouble() * 0.4 - 0.1);
            m.Cyll = Convert.ToDecimal(ran.NextDouble() * 30000);
            return AbpJson(m, null, null, JsonRequestBehavior.AllowGet, false, false);
        }
        public ActionResult MakeData()
        {
            Random ran = new Random();
            for (int i = 0; i < 70; i++)
            {
                var m = new HistoryData();
                m.MachineCode = "1103-" + ran.Next(1, 19);
                m.Yw = Convert.ToDecimal(ran.NextDouble() * 4000);
                m.Kd = Convert.ToDecimal(ran.NextDouble() * 90);
                m.Wd = Convert.ToDecimal(ran.NextDouble() * 100);
                m.GnYl = Convert.ToDecimal(ran.NextDouble() * 0.3);
                m.JtYl = Convert.ToDecimal(ran.NextDouble() * 0.4 - 0.1);
                m.Cyll = Convert.ToDecimal(ran.NextDouble() * 30000);
                _service.Add(m);
            }
            return Json(new ResultMsg());
        }
    }
}